Skip to content

Function Arguments

Detailed descriptions of the arguments that are passed to functions registered with the K-scaffold.

attributes

member

A representation of the sheet's attributes. This is a proxy for the actual object and will keep track of original values and updates that have been applied. Calling an attribute directly on the attributes value will return it's current value coerced into a number if it is numeric. Setting a property on the attributes object will add it the list of updates which will be applied the next time the set() method is called on attributes.

  • attributes - object -

    The raw original data of the character sheet.

  • updates - object -

    The raw data that will be saved to the character sheet once all operations have been completed.

  • set - function -

    Method to apply changes to the character sheet. This is called automatically at the end of the scaffold's event handling. Needs to be called manually if inside an asynchronous function, such as when using the startRoll sheetworker (or any of the scaffold aliases for startRoll). The method uses object destructuring syntax for the arguments it takes.

  • set.vocal - boolean -

    Whether the set is done silently or not. Should almost always be left at false. attributes.set({vocal:true})

  • set.callback - function -

    Callback function to be invoked once the setAttrs is complete. attributes.set({callback(){/*do a thing}})

  • attribute_name - any -

    Name of any attribute whose data from the character sheet you want to access. Will only return a value if the attribute was defined using the scaffold's pug mixins (e.g. +input). If the value of the attribute is numerical (e.g. "5"), it will be returned as a number. You can also apply changes by simply assigning a value to an attribute name (e.g. attributes.character_name = 'New Character').

  • repOrders - object -

    Object showing the ordered arrays for the reporder attributes for each repeating section. Indexed by repeating section name

  • repeating_section_name - Array.<object> -

    Name of a repeating section whose data you want to access (e.g. attributes.repeating_weapons). The data will be returned as an array with objects describing each row in the order they are on the sheet. Objects are indexed by rowID as well. Mutating array methods are replaced by the sort and move methods. Non mutating array methods can be used as normal.

  • repeating_section_name._section - string -

    the name of the repeating section. Used internally by the scaffold. Readonly.

  • move - function -

    Method for reordering rows.

  • move.startingPosition - number|string -

    the row id or position index for the row you want to move.

  • move.destination - number -

    The position in the section where you want the row to be moved to. If the position is greater than the length of the section, the row will be moved to the last position. If the position is negative, it will be moved to the start of the section.

  • move.silent - boolean -

    Whether the reordering should trigger setSectionOrder or not.

  • sort - function -

    Alias for the default Array.sort method. Functions as the default sort method, but has an optional second argument.

  • sort.callback - function -

    The function to use for determining the sort order. See the Array.sort documentation for details.

  • sort.silent - boolean -

    Whether to apply the sort to the display of the repeating section.

  • create - function -

    Method for creating a new row in a repeating section. Arguments for this method can be in any order. A row will not actually be created unless data is assigned to at least one attribute of the row, either at creation or later. Returns the object representing the new row.

  • create.custom - string -

    Custom text that replaces the starting characters of the rowID

  • create.data - object -

    what to set the attribute values of the row to. If not provided, the row object will be created, but no row will be created on the sheet until data is specified.

  • repeating_section_name.rowID_or_Index - object -

    Returns the object describing a row in a repeating section specified by row ID or indexed position. (e.g. attributes.repeating_weapons[0] returns the data for the first row in the weapons section)

    • @property {object} repeating_section_name.rowID_or_Index._id - The id of the row. Readonly.
    • @property {object} repeating_section_name.rowID_or_Index._section - The repeating section the row belongs to. Readonly.
  • repeating_section_name.rowID_or_Index.attribute_name - any -

    functions as an attribute_name call on the base attributes object. (e.g. attributes['repeating_weapons_-jJ2soils_name'] is equivalent to attributes.repeating_weapons['-jJ2soils'].name).

casc

member

Object that stores the default trigger information for all attributes. Indexed by attribute, button name, or fieldset name prefixed with attr_, act_, or fieldset_ respectively.

sections

member

An object that stores the rowID information for each repeating section on the sheet.

  • repeating_section_name - Array.<string> -

    The row IDs of a given repeating section. The repeating section name is used with the repeating_ prefix (e.g. sections['repeating_weapons']).

trigger

member

Object describing the attribute that is currently being worked on. In addition to the properties described here, the properties from the Roll20 event will also be present if the attribute was the original event. Additional properties may be present if you specified them when creating the input for the attribute.

  • name - string -

    The full name of the attribute.

  • triggeredFuncs - Array.<string> -

    Array of function names that will be called when this attribute is worked on.

  • calculation - string -

    The name of the function that is used to calculate the value of this attribute.

  • formula - string -

    The macro syntax formula to use to calculate this attributes value.

  • affects - Array.<string> -

    Array of attribute names that this attribute might affect.

  • addFuncs - Array.<string> -

    Functions that are called when the add row button is clicked for a customControlFieldset.

  • listener - string -

    What function was used to listen for changes to this attribute. Unless you have decided to implement your own event handling, this should always be "accessSheet".

  • type - string -

    What type of thing this trigger is for (e.g. number, action).

Released under the MIT License